package remote.activities;

import remote.adapters.FilesArrayAdapter;
import remote.controllers.FileBrowserController;
import remote.utils.XmlParser;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.Toast;

public class FileBrowserActivity extends Activity
{
	private FileBrowserController _controller;
	
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.file_browser);
		
		_controller = new FileBrowserController(this);
		Bundle bundle = getIntent().getExtras();
		
		if(bundle != null)
		{
			String data = bundle.getString(FileBrowserController.FILE_BROWSER_KEY);
			String[] files = XmlParser.parseXML(data);
			
			if(files != null)
			{
				ListView ddlFiles = (ListView)findViewById(R.id.file_browser_ddlFiles);
				ddlFiles.setAdapter(new FilesArrayAdapter(getBaseContext(), _controller, files));
				ddlFiles.setOnItemClickListener(_controller);
			}
		}
	}
}